package com.tyut.mapper;

import com.tyut.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
   // 根据用户名查询用户信息
    @Select("select * from user where username = #{name} and state = 0")
    User findByName(String username);

    // 插入用户信息
    @Insert("insert into user (username,password,create_time,update_time) " +
            "values(#{username},#{password},now(),now())")
    void add(String username, String password);

    // 更新用户信息
    @Update("update user set nickname=#{nickname},email=#{email},update_time=#{updateTime} where id=#{id}")
    void update(User user);

    // 更新用户头像
    @Update("update user  set user_pic=#{userPic},update_time=#{updateTime} where id=#{id}")
    void updateAvatar(User user);

    // 更新用户密码
    @Update("update user set password=#{password},update_time=#{updateTime} where id=#{id}")
    void updatePwd(User user);

    @Delete("delete from user where id = #{id}")
	void delete(Integer id);
//    @Select("select * from user where id != 0")
    List<User> getUser(String userRole,String username);
    @Update("update user set state = #{state} where id = #{id}")
    void updateState(Integer id, String state);
}
